Skip to content

Add Elasticsearch Java client plugin for 7.x-9.x#804

Open
wu-sheng wants to merge 10 commits intomainfrom
elasticsearch-java-plugin
Open

Add Elasticsearch Java client plugin for 7.x-9.x#804
wu-sheng wants to merge 10 commits intomainfrom
elasticsearch-java-plugin

Conversation

@wu-sheng
Copy link
Copy Markdown
Member

@wu-sheng wu-sheng commented Apr 9, 2026

Summary

  • Add new plugin for co.elastic.clients:elasticsearch-java, the modern Elasticsearch Java client that replaces the deprecated REST High Level Client
  • Covers both 7.x (RestClientTransport.performRequest directly) and 8.x/9.x (ElasticsearchTransportBase.performRequest) code paths using witness classes for version detection
  • Constructor interceptor extracts peer addresses from RestClient.getNodes()
  • performRequest interceptor creates ExitSpan with Elasticsearch/{endpoint.id()} operation name, db.type=Elasticsearch, SpanLayer.DB
  • Tested 27 versions across all minors: 7.15-7.17, 8.0-8.19, 9.0-9.3
  • Note: co.elastic.clients:elasticsearch-java was first published at 7.15.0, no earlier versions exist
  • Resolves [Bug] Skywalking Java Agent Fails to Collect Elasticsearch Query Requests After ES Client Upgrade skywalking#13447

Test plan

  • CI E2E tests for 7.x versions (7.15.2, 7.16.3, 7.17.29)
  • CI E2E tests for 8.x versions (8.0.1, 8.1.3, 8.2.3, 8.3.3, 8.4.3, 8.5.3, 8.6.2, 8.7.1, 8.8.2, 8.9.2, 8.10.4, 8.11.4, 8.12.2, 8.13.4, 8.14.3, 8.15.5, 8.16.7, 8.17.11, 8.18.8, 8.19.14)
  • CI E2E tests for 9.x versions on JDK 17 (9.0.11, 9.1.12, 9.2.8, 9.3.4)
  • Verify trace segments include correct operation names (Elasticsearch/create, Elasticsearch/index, etc.)
  • Verify peer addresses are captured correctly
  • Verify both 7.x and 8.x/9.x code paths via witness class activation

Add plugin for co.elastic.clients:elasticsearch-java, the modern
Elasticsearch Java client that replaces the deprecated REST High Level
Client. Covers both 7.x (RestClientTransport.performRequest) and
8.x/9.x (ElasticsearchTransportBase.performRequest) code paths using
witness classes for version detection.

Tested versions: 7.17.22, 8.5.3, 8.12.2, 8.17.0, 9.0.0.
Local verification passed for 8.17.0.
@wu-sheng wu-sheng added enhancement New feature or request feature labels Apr 9, 2026
@wu-sheng wu-sheng added this to the 9.7.0 milestone Apr 9, 2026
wu-sheng added 9 commits April 9, 2026 23:08
elasticsearch-java 9.0.0 is compiled for JDK 17 (class version 61),
so it cannot be tested in the JDK 8 test container. Split into a
separate elasticsearch-java-9.x-scenario using Spring Boot 3.x and
JDK 17 compiler target, added to plugins-jdk17-test.1.yaml.
Fix jar name in assembly.xml, correct support-version.list,
and add to plugins-jdk17-test.1.yaml instead of replacing the
JDK 8 scenario entry.
…oconfig

- Use ES 9.0.0 server image instead of 8.17.0 for the 9.x scenario
- Exclude ElasticsearchClientAutoConfiguration to avoid Spring Boot
  auto-config conflict with ES Java client constructor changes
- Verified locally: 9.0.0 passed
Cover every minor version per test policy:
- 7.x: 7.15.2, 7.16.3, 7.17.29 (library started at 7.15)
- 8.x: 8.0.1 through 8.19.14 (all 20 minors)
- 9.x: 9.0.11, 9.1.12, 9.2.8, 9.3.4
- Add RestClientTransportV1Instrumentation for 7.15.x where
  RestClientTransport is in co.elastic.clients.base.rest_client
  (moved to co.elastic.clients.transport.rest_client in 7.16+)
- Add TransportPerformRequestV1Interceptor that derives operation
  names from request class names since Endpoint.id() doesn't exist
  in 7.15.x
- Add separate elasticsearch-java-7.15.x-scenario test (JDK 8)
- Remove 7.15.x from main scenario (incompatible imports)
- Fix JDK17 workflow: run elasticsearch-java-9.x-scenario instead
  of duplicating the main scenario
- Use FieldValue.of() instead of query(String) for 7.x compatibility
  (query(String) shorthand only exists in 8.0+)
- Fix 8.16/8.17 versions: use 8.16.6/8.17.10 to match available
  elasticsearch-rest-client versions
- Fix 9.x versions: use 9.0.8/9.1.10/9.2.8/9.3.3 to match available
  elasticsearch-rest-client versions
- All 29 versions verified locally against Maven Central
- Extract index name from Endpoint.requestUrl() and set as db.instance tag
- Aligns with existing elasticsearch-5.x/6.x/7.x plugins that capture
  db.type, db.instance, and db.statement tags
- Update all three scenario expectedData.yaml files
- Add ElasticsearchPluginConfig with TRACE_DSL and
  ELASTICSEARCH_DSL_LENGTH_THRESHOLD (same config keys as existing
  elasticsearch plugins: plugin.elasticsearch.trace_dsl)
- Capture request body via RequestBase.toString() which serializes
  to JSON, same approach as existing ES 6.x/7.x plugins
- Guarded by TRACE_DSL config (default false), with length threshold
- Update all three scenario expectedData.yaml files
7.15.x (Sep 2021) had unstable API with different package structure
(_core vs core, base.rest_client vs transport.rest_client). The API
stabilized from 7.16.0+. Plugin now covers 7.16.x-9.x.

All remaining versions verified locally.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant